João Távora [Tue, 10 Aug 2021 19:28:35 +0000 (20:28 +0100)]
Let eglot-flymake-backend be in flymake-d-functions even if eglot off
This is useful when using eglot-stay-out-of and a pattern like:
(defun my/js-mode-hook ()
(add-hook 'flymake-diagnostic-functions 'some-eslint-backend nil t))
(setq-local eglot-stay-out-of '(flymake))
(add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t))
(add-hook 'js-mode-hook 'my/js-mode-hook)
Then, _both_ backends will run unconditionally, but Eglot backend only
actually reports diagnostics if Eglot is on.
* eglot.el (eglot-flymake-backend): If buffer isn't being managed
by Eglot, behave as a noop.
Brian Leung [Sun, 31 Jan 2021 01:33:08 +0000 (17:33 -0800)]
Add support for locationlink
Fix https://github.com/joaotavora/eglot/issues/711.
LocationLink was added in version 3.14 of the protocol and is
sometimes used in lieu of Location for definition- and
reference-related requests.
* eglot.el (eglot--lsp-interface-alist): Update with LocationLink.
(eglot-client-capabilities): Advertise
textDocument.{definition,declaration,implementation,typeDefinition}.linkSupport.
(eglot--lsp-xrefs-for-method): Accept LocationLinks.
Co-authored-by: João Távora <joaotavora@gmail.com
GitHub-reference: close https://github.com/joaotavora/eglot/issues/712
João Távora [Sun, 13 Jun 2021 22:07:42 +0000 (23:07 +0100)]
Transpose order of "pylsp" and "pyls" alternatives
When operating remotely, searching for an executable that don't exist
takes longer than usual. Better to put the most likely server first
in the list to minimize the slowdown.
* eglot.el (eglot-server-programs): Transpose python mode alternatives
GitHub-reference: per https://github.com/joaotavora/eglot/issues/703
João Távora [Sun, 13 Jun 2021 09:55:24 +0000 (10:55 +0100)]
Don't call eglot--executable-find more than needed
* eglot.el (eglot-alternatives): Complexify.
(eglot--guess-contact): No need to 'executable-find' if path
absolute.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/703
Liu Hui [Fri, 11 Jun 2021 22:49:19 +0000 (06:49 +0800)]
Consider tramp in eglot-alternatives
* eglot.el (eglot-alternatives): Use eglot--executable-find.
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/702
João Távora [Wed, 26 May 2021 17:51:30 +0000 (18:51 +0100)]
Use project-files to know which directory watchers to skip
The directory-finding logic is probably a bit slower than using
eglot--directories-recursively, but since it honours `.gitignores` and
ignores more directories it's much faster overall. And guaranteed to
create less watchers.
Thanks to Dmitry Gutov <dgutov@yandex.ru> for the idea.
* eglot.el (eglot--directories-recursively): Remove.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/697
João Távora [Wed, 26 May 2021 14:23:29 +0000 (15:23 +0100)]
Hard code an exception to "node_modules" directores
* eglot.el (eglot--directories-recursively): Fix.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/697
GitHub-reference: per https://github.com/joaotavora/eglot/issues/645
João Távora [Wed, 26 May 2021 14:21:06 +0000 (15:21 +0100)]
Again speed up directory watching
Previously, given a number of globs, Eglot would try to place system
watchers only in those subdirectories that could potentially be
matched by a glob. This meant traversing the whole tree, which could
be impractical. Just place watchers in every subdirectory of the
project (you may run out of watchers).
* eglot.el (eglot-register-capability): Simplify.
(eglot--files-recursively): Delete.
(eglot--directories-recursively): Fix.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/697
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/645
João Távora [Sat, 22 May 2021 10:49:47 +0000 (11:49 +0100)]
Support multiple servers out-of-box for same mode
Also per https://github.com/joaotavora/eglot/issues/537.
* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it. Use clangd and pylsp.
* NEWS.md: Mention feature.
* README.md (Connecting to a server): Mention pylsp and clangd.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/688
Augusto Stoffel [Sat, 22 May 2021 10:53:38 +0000 (12:53 +0200)]
Allow staying out of flymake-mode, eldoc-mode
* eglot.el (eglot--managed-mode): don't enable flymake or eldoc when
those symbols belong to eglot-stay-out-of.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/671
Michael Livshin [Sat, 15 Dec 2018 01:17:32 +0000 (01:17 +0000)]
Manage cross-referenced files outside project in same server
Close https://github.com/joaotavora/eglot/issues/686, Close https://github.com/joaotavora/eglot/issues/695.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-extend-to-xref): new defcustom, default to
nil.
(eglot--servers-by-xrefed-file): new hash table, mapping file names
to servers.
(eglot--managed-mode): use eglot-current-server, instead of
eglot--cached-server directly.
(eglot--current-server-or-lose): ditto.
(eglot--maybe-activate-editing-mode): ditto.
(eglot-current-server): move all cached-server update logic here -- if
eglot--cached-server is nil, try to find it using current project or
(optionally) xref location.
(eglot--xref-make-match): record the xref location.
* README.md (Customization): Mention new defcustom.
* NEWS.md: Mention new feature
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/76
Jim Porter [Thu, 13 May 2021 15:55:31 +0000 (08:55 -0700)]
Correct path/uri when using tramp from ms windows
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--connect): Ensure drive letter doesn't sneak into
rootPath. (eglot--path-to-uri): Only add a leading "/" for local MS
Windows paths. (eglot--uri-to-path): Only remove leading "/" from
local MS Windows paths.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/679
João Távora [Thu, 13 May 2021 09:09:20 +0000 (10:09 +0100)]
Provide context for finer project-find-functions
* eglot.el (eglot--guess-contact): Use eglot--current-project.
(eglot): Adjust docstring.
(eglot-lsp-context): New variable.
(eglot--current-project): New helper.
(eglot--maybe-activate-editing-mode, eglot--eclipse-jdt-contact):
Use eglot--current-project.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/687
Steve Purcell [Fri, 30 Apr 2021 08:32:07 +0000 (20:32 +1200)]
Fix emacs 28 warning by avoiding positional args in define-minor-mode
* eglot.el (eglot--managed-mode): Avoid positional args.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/685
Steve Purcell [Thu, 29 Apr 2021 23:09:04 +0000 (11:09 +1200)]
Allow lsp languageid to be overridden via eglot-server-programs
Close https://github.com/joaotavora/eglot/issues/678. Per https://github.com/joaotavora/eglot/issues/677
* eglot-tests.el (eglot--guessing-contact): Add
GUESSED-LANG-ID-SYM param.
(eglot-server-programs-guess-lang): New test.
* eglot.el (eglot-server-programs): Augment entries for caml-mode
and tuareg-mode. Enhance docstring.
(eglot--lookup-mode): New helper.
(eglot--guess-contact): Call eglot--lookup-mode.
(eglot, eglot-reconnect): Pass language-id to eglot--connect
(eglot--connect): Receive LANGUAGE-ID
(eglot--TextDocumentItem): Simplify. Use
`eglot--current-server-or-lose'
* README.md (Handling quirky servers): Mention new feature.
Co-authored-by: João Távora <joaotavora@gmail.com>
Augusto Stoffel [Wed, 28 Apr 2021 10:41:19 +0000 (11:41 +0100)]
Add a completion-category-defaults entry
Setting completion-styles buffer-locally is harder to customize and
can break some completion UIs.
Emacs bughttps://github.com/joaotavora/eglot/issues/48073
* eglot.el: Add a completion-category-defaults entry, if applicable.
(eglot--managed-mode): Don't set `completion-styles'
(eglot-completion-at-point): Add style metadata to
completion table.
Steve Purcell [Sun, 25 Apr 2021 22:51:44 +0000 (10:51 +1200)]
Switch default langserver for ocaml to ocamllsp
The repo for ocaml-language-server has been archived and inactive
for quite some time:
https://github.com/ocaml-lsp/ocaml-language-server
Meanwhile, ocaml-lsp is the generally-preferred option, and is actively
maintained in the ocaml org itself:
https://github.com/ocaml/ocaml-lsp/
* eglot.el (eglot-server-programs): switch caml-mode entry.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/677
João Távora [Fri, 23 Apr 2021 07:49:02 +0000 (08:49 +0100)]
Declare eglot--cached-server before use
Per https://github.com/joaotavora/eglot/issues/670.
Otherwise the dynamic binding of it in in eglot--connect won't work.
* eglot.el (eglot--cached-server): Move up.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/673
João Távora [Tue, 20 Apr 2021 17:39:54 +0000 (18:39 +0100)]
Make eglot-current-server work in notification handlers
* eglot.el (eglot--connect): Ensure `eglot--cached-server` bound
when calling notification/request methods.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/670
João Távora [Tue, 13 Apr 2021 00:16:31 +0000 (01:16 +0100)]
Add a passing test demonstrating clangd + tramp works
... It works at least within the minimal, well-controlled reproducible
settings of this test. Maybe if we knew something more about the
setup of the user who submitted this report we would be able to
concoct a failing test, but we don't.
* eglot-tests.el (subr-x): Require it
(eglot--make-file-or-dir): Return expanded file name.
(eglot-tests--lsp-abiding-column-1): New helper.
(eglot-lsp-abiding-column): Use it.
(eglot--tramp-test): Fix `skip-unless` condition.
(eglot--tramp-test-2): New test.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/667
Dmitry Gutov [Mon, 12 Apr 2021 23:30:11 +0000 (02:30 +0300)]
Merge pull request from mohkale/company-kind
(feature): Add :company-kind to eglot-completion-at-point
GitHub-reference: https://github.com/joaotavora/eglot/issues/656
Mohsin Kaleem [Mon, 29 Mar 2021 21:32:33 +0000 (22:32 +0100)]
Add :company-kind to eglot-completion-at-point
* eglot.el (eglot-completion-at-point): Add a :company-kind field to the
completion-at-point function so that company can associate completion
candidates with lsp types.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/652
Mohsin Kaleem [Mon, 29 Mar 2021 21:17:07 +0000 (22:17 +0100)]
Highlight relevant part of xref hits using xref-match face
Also close https://github.com/joaotavora/eglot/issues/657.
(eglot--xref-make-match): Use face 'xref-match instead of 'highlight.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/650
João Távora [Sat, 10 Apr 2021 13:31:14 +0000 (14:31 +0100)]
Attempt to speed up initial directory/glob correspondence
In https://github.com/joaotavora/eglot/issues/602, not only a new glob processing system was implemented, but
also a new, more correct, way to look for directories that might hold
files matched by one of these globs.
Answering this question is important because the file watchers for
'workspace/didChangeWatchedFiles' are placed on a per-directory basis.
Previously, a glob such as /foo/**/bar/*.el would fail to produce
practical file-watching effects because /foo/**/bar/ isn't really a
directory.
However, answering this question is also expensive, as the globs sent
by the LSP server are meant to match files, not directories. The only
way is to list all files under the project's root directory and test
each glob on each one. If it matches at least one file, that file's
directory is meant to be watched.
We suspect that in https://github.com/joaotavora/eglot/issues/645 and https://github.com/joaotavora/eglot/issues/633 we are falling victim to LSP server
who serve a tremendous unoptimized number of globs, one for each file.
So instead of sending just '/foo/**/bar/*.el' they send
'/foo/**/bar/quux.el', '/foo/**/bar/quuz.el', etc... which would
tremendeously slow down the process. But this is only a suspicion.
This commit tries some simple optimizations: if a directory is known
to be watch-worthy becasue one of its files matched a single glob, no
more files under that directory are tried. This should help somewhat.
Also fixed a bug in 'eglot--files-recursively', though I suspect that
doesn't make that much of a difference.
* eglot.el (eglot--directories-matched-by-globs): New helper.
(eglot--files-recursively): Fix bug.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/645
João Távora [Thu, 1 Apr 2021 23:21:27 +0000 (00:21 +0100)]
Generalize eglot-flymake-backend
Loosen coupling between eglot-flymake-backend and flymake-mode. The
flymake-mode check in 'eglot-handle-notification publishDiagnostics'
was a hack (and it wasn't even functioning correctly on M-x
eglot-shutdown/eglot-reconnect).
This should also allow eglot-flymake-backend to be driven by
diagnostic-annotating frontends other than Flymake, such as the
popular Flycheck package.
* eglot.el (eglot--managed-mode): Use eglot--report-to-flymake.
(eglot-handle-notification textDocument/publishDiagnostics): Use
eglot--report-to-flymake.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/596
rvs314 [Fri, 26 Mar 2021 10:08:03 +0000 (06:08 -0400)]
Offer better control over "languageid" value sent to lsp
Handles the issue of languages whose major mode has a
different name than the name that the LSP server expects for
the language. One can now:
(put 'favourite-major-mode 'eglot-language-id "foobarbaz")
And "foobarbaz" will be used as the LSP "languageId" value.
* eglot.el (eglot--TextDocumentItem): Consult 'eglot-language-id.
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/525
Johnathan C. Maudlin [Fri, 19 Mar 2021 20:10:43 +0000 (16:10 -0400)]
Add support for zls, the zig language server
* eglot.el (eglot-server-programs): Add zig-mode entry.
* README.md (Connecting to a server): Mention zls.
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/646
bc² [Mon, 15 Mar 2021 09:49:07 +0000 (06:49 -0300)]
Add new command eglot-shutdown-all
Also closes https://github.com/joaotavora/eglot/issues/644
Co-authored-by: João Távora <joaotavora@gmail.com>
Copyright-paperwork-exempt: yes
* NEWS.md: mention new command
* README.md (Commands and keybindings): mention new command. Tweak
documentation for eglot-shutdown and eglot-reconnect.
* eglot.el (eglot-shutdown): Tweak docstring.
(eglot-shutdown-all): New command.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/643
João Távora [Sat, 6 Mar 2021 21:20:42 +0000 (21:20 +0000)]
Autoload eglot-workspace-configuration's safe-l-v spec
This is useful for those who edit files in a certain source tree where
this directory-local variable is set, but without having yet loaded
eglot.el. Those users would be bothered by the usual
risky-local-variable prompt.
* eglot.el (eglot-workspace-configuration): Add autoload cookie.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/555
Brian Leung [Sat, 6 Mar 2021 21:17:07 +0000 (13:17 -0800)]
Indicate support for activeparameter
* eglot.el (eglot-client-capabilities): Indicate :activeParameterSupport.
Fixup of commit
bdf57d5d4e888a6a7b4066b87497da8a8d9e36de.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/605
João Távora [Sat, 6 Mar 2021 21:15:33 +0000 (21:15 +0000)]
Simplify eglot--apply-workspace-edit
Suggested by Brian Leung.
* eglot.el (eglot--apply-workspace-edit): simplify
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/620
Augusto Stoffel [Thu, 25 Feb 2021 14:48:41 +0000 (15:48 +0100)]
Remove highlight overlays immediately when symbol edited
* eglot.el (eglot--highlight-piggyback): Add modification-hooks
property to the created overlays.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/626
Theodor Thornhill [Sat, 6 Mar 2021 20:18:48 +0000 (21:18 +0100)]
Convert colon to hex in uri
On windows, in the path portion of the URI, ':' must be hexified to
'%3A'. In the URL scheme, the ':' stays.
* eglot.el (eglot--uri-path-allowed-chars): define what characters are
allowed in path portion of URI.
* eglot.el (eglot--path-to-uri): ensure colon in 'file://' stays, but
and others are hexified.
Co-authored-by: João Távora
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/638
Brian Cully [Tue, 2 Mar 2021 21:13:07 +0000 (16:13 -0500)]
Add tramp support
Also close https://github.com/joaotavora/eglot/issues/463, close https://github.com/joaotavora/eglot/issues/84.
Thanks to Brian Cully for the original simple idea. The basic
technique is to pass :file-handler t to make-process, then tweak
eglot--uri-to-path and eglot--path-to-uri, along with some other
functions, to be aware of "trampy" paths".
Crucially, a "stty hack" was needed. It has been encapsulated in a
new a new eglot--cmd helper, which contains a comment explaining the
hack.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--executable-find): Shim two-arg executable-find
function only available on Emacs 27.
(eglot--guess-contact): Use eglot--executable-find.
(eglot--cmd): New helper.
(eglot--connect): Use eglot--cmd. Use :file-handler arg to
make-process.
(eglot--connect, eglot--path-to-uri): Be aware of trampy file
names.
* eglot-tests.el (eglot-tests--auto-detect-running-server-1): New helper.
(eglot--guessing-contact): Better mock for executable-find.
(eglot--tramp-test): New test.
* NEWS.md: mention TRAMP support.
* README.md: mention TRAMP support.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/637
Theodor Thornhill [Wed, 3 Mar 2021 10:08:24 +0000 (11:08 +0100)]
Correctly protect against zero-length completion items
Close https://github.com/joaotavora/eglot/issues/636.
* eglot.el (eglot-completion-at-point): check for zero length string in proxy
rather than the item.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/635
Theodor Thornhill [Sat, 27 Feb 2021 10:19:35 +0000 (11:19 +0100)]
Protect against empty uris on windows
Per https://github.com/joaotavora/eglot/issues/630.
* eglot.el (eglot--uri-to-path): Check string length
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/610
João Távora [Fri, 26 Feb 2021 20:11:08 +0000 (20:11 +0000)]
Urify better
See also
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#uri.
* eglot.el (eglot--path-to-uri): use directory-file-name.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/627
João Távora [Fri, 26 Feb 2021 19:30:30 +0000 (19:30 +0000)]
Fixup last commit to fix
* eglot.el (eglot-handle-request): Fixup. Use let*
GitHub-reference: https://github.com/joaotavora/eglot/issues/627
João Távora [Fri, 26 Feb 2021 18:49:59 +0000 (18:49 +0000)]
Handle empty actions array in window/showmessagerequest
* eglot.el (eglot-handle-request window/showMessageRequest):
Handle empty actions.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/627
João Távora [Wed, 24 Feb 2021 11:27:59 +0000 (11:27 +0000)]
Handle null reply for textdocument/definition
* eglot.el (eglot--lsp-xrefs-for-method): Handle null response
from textDocument/definition & friends.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/625
Jonathan del Strother [Sun, 21 Feb 2021 10:07:57 +0000 (10:07 +0000)]
Silence messages while formatting markup
Also fix https://github.com/joaotavora/eglot/issues/501.
Prior to this, activating gfm-view-mode could echo messages
like "markdown-mode math support enabled" to the minibuffer.
Message are both silenced from from the minibuffer and the
*Messaages* log.
Co-authored-by: João Távora <joaotavora@gmail.com>
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/502
João Távora [Wed, 3 Feb 2021 10:41:40 +0000 (10:41 +0000)]
Simplify dir-watching strategy of w/didchangewatchedfiles
Instead of massaging the globPattern to match directories instead of
files, which is fragile, gather the list of directoris to watch by
matching the globPattern against every file recursively (except hidden
files and dirs).
This is still not 100% correct, but should do the right thing is most
cases. Notably, if the correct dirs are being watched, the glob
pattern is matched against all existing and new files in those
directories, which does include hidden files.
* eglot.el (eglot-register-capability): match file globs against
files only.
(eglot--files-recursively): Rename from eglot--directories-recursively.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/602
João Távora [Wed, 3 Feb 2021 00:43:35 +0000 (00:43 +0000)]
Tweak glob-parsing grammar
Alternative groups {} don't bork on forward slash.
* eglot.el (eglot--glob-parse): Tweak {} grammar.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/602
Philip Kaludercic [Mon, 1 Feb 2021 18:20:37 +0000 (18:20 +0000)]
Make eglot-ignored-server-capabilites defcustom a set
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-ignored-server-capabilites): Now a set.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/467
João Távora [Mon, 1 Feb 2021 17:23:07 +0000 (17:23 +0000)]
Speed up glob matching 2x
with-temp-buffer was taking a lot of time, presumably because it kills
the buffer. Since emacs is single-threaded, we can safely reuse a
single buffer.
* eglot.el (eglot--glob-parse): Simplify grammar.
(eglot--glob-compile): Don't with-temp-buffer.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/602
Felicián Németh [Mon, 1 Feb 2021 16:02:58 +0000 (17:02 +0100)]
Support phps-mode
phps-mode is available from ELPA, php-mode isn't.
* eglot.el (eglot-server-programs): Recognize phps-mode as a PHP mode.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/418
Brian Leung [Mon, 1 Feb 2021 15:44:52 +0000 (07:44 -0800)]
Remove duplicate entry for "registration" lsp type
* eglot.el (eglot--lsp-interface-alist): Remove extra Registration entry.
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/612
João Távora [Mon, 1 Feb 2021 15:39:15 +0000 (15:39 +0000)]
Prefer typescript-language-server for js&ts
* README.md (Connecting to a server): Prefer
typescript-language-server.
* eglot.el (eglot-server-programs): Use
typescript-language-server.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/566
João Távora [Mon, 1 Feb 2021 14:03:23 +0000 (14:03 +0000)]
Also override global flymake-diagnostic-functions
The global value of the flymake-diagnostic-functions is likely to be
of little use in Eglot-managed buffers, so don't run it. Likely the
value flymake-proc-legacy-flymake is there which is not only likely of
little uses but also causes trouble in some situations.
The user can easily avert this by leveraging the variable
eglot-stay-out-of.
* eglot.el (eglot--managed-mode): Don't run global
flymake-diagnostic-functions.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/616
Brian Leung [Mon, 1 Feb 2021 10:44:38 +0000 (02:44 -0800)]
Explicitly require seq.el
`seq-empty-p' is not autoloaded in Emacs >= 26.3, so it must be
explicitly required.
* eglot.el: Require seq.el.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/613
Brian Leung [Mon, 1 Feb 2021 01:28:49 +0000 (17:28 -0800)]
Support activeparameter property for signatureinformation
SignatureInformation.activeParameter is new in version 3.16.0 of the
protocol. When non-nil, it is used in place of
SignatureHelp.activeParameter. The latter was deemed insufficient in
languages where multiple signatures for the same function may exist
with arbitrary order of parameters, like Python.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--lsp-interface-alist): Add
SignatureInformation.activeParameter.
* eglot.el (eglot--sig-info): Prioritize
SignatureInformation.activeParameter over
SignatureHelp.activeParameter.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/605
João Távora [Sun, 31 Jan 2021 18:18:02 +0000 (18:18 +0000)]
Fully handle lsp glob syntax
Thanks to Brian Leung and Dan Peterson for testing and helping me spot
bugs.
* eglot-tests.el (eglot--glob-match): New test.
* eglot.el (eglot--wildcard-to-regexp): Delete.
(eglot-register-capability): Rework.
(eglot--glob-parse, eglot--glob-compile, eglot--glob-emit-self)
(eglot--glob-emit-**, eglot--glob-emit-*, eglot--glob-emit-?)
(eglot--glob-emit-{}, eglot--glob-emit-range)
(eglot--directories-recursively): New helpers.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/602
João Távora [Sat, 30 Jan 2021 18:01:19 +0000 (18:01 +0000)]
Flush pending changes to server before code actions request
Otherwise the actions returned by the server might be stale when the
user selects them.
* eglot.el (eglot-code-actions): Issue jsonrpc-request with deferred=t.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/609
João Távora [Fri, 29 Jan 2021 16:27:55 +0000 (16:27 +0000)]
#fix 608: fix bug in eglot-code-actions
Suggested by GitHub user "vconcat".
* eglot.el (eglot-code-actions): Use a vector for transmitting
action-kind.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/606
João Távora [Thu, 28 Jan 2021 18:56:22 +0000 (18:56 +0000)]
* eglot.el (eglot): tweak docstring grammar.
Andrii Kolomoiets [Thu, 28 Jan 2021 18:36:11 +0000 (20:36 +0200)]
Offer shortcut commands to commonly invoked code actions
See also https://github.com/joaotavora/eglot/issues/598.
Make eglot-code-actions accept a new action-kind argument. If there
is only one action of that kind, apply it. This allows us to create
actions shortcuts like eglot-code-action-organize-imports, etc.
* eglot.el (eglot-code-actions): Accept new argument action-kind.
(eglot--code-action): New function-defining helper macro.
(eglot-code-action-organize-imports)
(eglot-code-action-extract)
(eglot-code-action-inline)
(eglot-code-action-rewrite)
(eglot-code-action-quickfix): New commands.
* README.md: Mention new feature.
* NEWS.md: Mention new feature.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/411
ssnnoo [Wed, 27 Jan 2021 09:10:07 +0000 (09:10 +0000)]
Add fortls for fotran (f90-mode)
* eglot.el (eglot-server-programs): Add fortls
* README.md: mention fortls
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/603
Brian Leung [Wed, 27 Jan 2021 22:43:15 +0000 (14:43 -0800)]
Add rnix-lsp server for nix-mode, community suggestion
* eglot.el (eglot-server-programs): Add rnix-lsp
* README.md: mention rnix-lsp
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/599
Felicián Németh [Sat, 11 Jan 2020 19:12:26 +0000 (20:12 +0100)]
Fix eglot-completion-at-point for multiple matches
The test-completion case shouldn't return t when there are multiple
matches. Similarly, the try-completion should return t only if the
match is exact. See (info "(elisp)Programmed Completion").
* eglot.el (eglot-completion-at-point): Instead of testing
memberships, use test-completion and try-completion suggested
by (info "(elisp)Programmed Completion").
* eglot-tests.el (non-unique-completions): Add new test.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/365
Andrii Kolomoiets [Sat, 16 Jan 2021 11:42:32 +0000 (13:42 +0200)]
Run exit-function only for finished completion
Per https://github.com/joaotavora/eglot/issues/594.
* eglot.el (eglot-completion-at-point): Respect 'status' argument in
completion's exit function.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/592
Augusto Stoffel [Wed, 13 Jan 2021 18:43:08 +0000 (19:43 +0100)]
Use `path-separator', not ":", in eclipse/jdt custom code
This is needed on Windows.
* eglot.el (eglot--eclipse-jdt-contact): Replace literal ":" by `path-separator'.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/513
Augusto Stoffel [Wed, 13 Jan 2021 18:41:10 +0000 (19:41 +0100)]
Define a face for symbol highlight
Also per https://github.com/joaotavora/eglot/issues/583.
* eglot.el (eglot-highlight-symbol-face): New face.
(eglot--highlight-piggyback): Use it.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/584
João Távora [Wed, 13 Jan 2021 15:13:32 +0000 (15:13 +0000)]
Unbreak interactivee eglot--connect for complex contact specs
The previous commit for https://github.com/joaotavora/eglot/issues/526 was completely botched. One has to check
current-prefix-arg for the presence of C-u, not eglot--guess-contact
INTERACTIVE arg.
* eglot.el (eglot--guess-contact): Be more careful when
processing guess.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/593
João Távora [Sun, 10 Jan 2021 16:42:59 +0000 (16:42 +0000)]
C-u m-x eglot discards class guessed by eglot--guess-contact
This will prevent C-u M-x eglot RET rust-analyzer from bringing into
play the eglot-rls server class, which is only valid for the default
RLS server.
Found when testing for https://github.com/joaotavora/eglot/issues/526, though this bug might not necessarily be
the problem being reported there.
* eglot.el (eglot--guess-contact): Don't assume guessed class if
INTERACTIVE.
Jürgen Hötzel [Tue, 5 Jan 2021 10:56:06 +0000 (11:56 +0100)]
Flex completion style is not available on emacs < 27
* eglot.el (eglot--managed-mode): check if flex style available
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/582
João Távora [Tue, 22 Dec 2020 17:35:08 +0000 (17:35 +0000)]
Don't block in eglot-imenu if performing non-essential task
eglot-imenu is used by imenu which in turn is used by which-func-mode
called from an idle timer. We don't want it to block in that
situation. Latest which-func mode now sets "non-essential" when
performing its duties, so we leverage that in eglot-imenu.
* eglot.el (eglot-imenu): Use non-essential.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/212
João Távora [Tue, 22 Dec 2020 17:31:52 +0000 (17:31 +0000)]
Use flex completion if available by default
* eglot.el (eglot--managed-mode): Set completion-styles.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/575
João Távora [Wed, 16 Dec 2020 16:40:41 +0000 (16:40 +0000)]
Bump eglot version to 1.7
* eglot.el (Version): Bump to 1.7.
(Package-Requires): Bump dependency versions.
João Távora [Wed, 16 Dec 2020 16:37:31 +0000 (16:37 +0000)]
Allow eglot to stay out of xref configuration
* eglot.el (eglot-stay-out-of): Rework docstring.
(eglot--managed-mode): Can now stay out of xref.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/569
João Távora [Wed, 16 Dec 2020 10:22:56 +0000 (10:22 +0000)]
Cosmetic whitespace fix (indentation, long lines, tabs->spaces)
* eglot.el (eglot-server-programs, for, eglot--after-change)
(eglot-code-actions, eglot-register-capability)
(eglot-register-capability): Fix whitespace.
TANIGUCHI Kohei [Wed, 16 Dec 2020 10:19:30 +0000 (19:19 +0900)]
Use haskell-language-server in eglot-server-programs
Use haskell-language-server instead of deprecated Haskell IDE Engine
https://github.com/haskell/haskell-language-server
https://github.com/haskell/haskell-ide-engine#deprecated
* README.md: Replace Haskell IDE Engine with haskell-language-server
* eglot.el (eglot-server-programs): Replace hie-wrapper with
haskell-language-server-wrapper
Copyright-paperwork-exempt: yes
GitHub-reference: close https://github.com/joaotavora/eglot/issues/572
João Távora [Tue, 15 Dec 2020 12:24:13 +0000 (12:24 +0000)]
Robustify previous fix of onchange breakage
From the in-code comments:
;; githubhttps://github.com/joaotavora/eglot/issues/259 and githubhttps://github.com/joaotavora/eglot/issues/367: With `capitalize-word' or somesuch,
;; `before-change-functions' always records the whole word's `b-beg'
;; and `b-end'. Similarly, when coalescing two lines into one,
;; `fill-paragraph' they mark the end of the first line up to the end
;; of the second line. In both situations, args received here
;; contradict that information: `beg' and `end' will differ by 1 and
;; will likely only encompass the letter that was capitalized or, in
;; the sentence-joining situation, the replacement of the newline with
;; a space. That's we keep markers _and_ positions so we're able to
;; detect and correct this. We ignore `beg', `len' and
;; `pre-change-len' and send "fuller" information about the region
;; from the markers. I've also experimented with doing this
;; unconditionally but it seems to break when newlines are added.
* eglot.el (eglot--after-change): Robustify fix.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/367
João Távora [Mon, 14 Dec 2020 17:08:26 +0000 (17:08 +0000)]
Don't let m-x fill-paragraph break didchange
M-x fill-paragraph represents some paragraph-fillling changes very
summarily. Filling
1 // foo
2 bar
Into
1 // foo bar
Only makes two changes: a deletion of the "// " and a replacement of a
newline with a space character. The second change fooled Eglot's fix
for https://github.com/joaotavora/eglot/issues/259, by making a change similar to the one it is made to detect
and correct. That fix should taget things that happen on the same
line, this not being one of those things.
* eglot.el (eglot--after-change): Only apply fix to https://github.com/joaotavora/eglot/issues/259 if
case-fiddling happens on same line.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/367
João Távora [Tue, 3 Nov 2020 10:26:03 +0000 (10:26 +0000)]
Don't force eglot-strict-mode completely in eglot--dcase
Doing so was by design, since there's much ambiguity between the
CodeAction and Command objects. But 'disallow-non-standard-keys is
not necessary to disambiguate, and proved harmful in this bug.
* eglot.el (eglot--dcase): Don't disallow
(eglot--check-dspec): Fix docstring.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/558
Damien Merenne [Wed, 28 Oct 2020 20:40:32 +0000 (21:40 +0100)]
Handle lsp 3.15's ispreferred code action property
* eglot.el (eglot--lsp-interface-alist): Add :isPreferred to CodeAction.
(eglot-client-capabilities): Announce :isPreferredSupport.
(eglot-code-actions): Consider preferred CodeAction item.
Co-authored-by: João Távora <joaotavora@gmail.com>
GitHub-reference: close https://github.com/joaotavora/eglot/issues/558
João Távora [Tue, 1 Sep 2020 18:10:55 +0000 (19:10 +0100)]
Don't send json null (elisp nil) down the wire
* eglot.el (eglot-initialization-options)
(eglot-client-capabilities): Use eglot--{}, not nil.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/300
R Primus [Sun, 30 Aug 2020 12:54:14 +0000 (13:54 +0100)]
Unbreak haskell's hie-wrapper built-in incantation
* eglot.el (eglot-server-programs): Add required argument for hie-wrapper
Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/528
Paul M. Rodriguez [Fri, 21 Aug 2020 22:27:40 +0000 (17:27 -0500)]
Provide suitable default to m-x eglot-rename
Copyright-paperwork-exempt: Yes
* eglot (eglot-rename): Provide a default value.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/524
João Távora [Sun, 16 Aug 2020 18:10:23 +0000 (19:10 +0100)]
Correct paren mismatch blunder introduced by earlier commit
Per https://github.com/joaotavora/eglot/issues/512.
* eglot.el (eglot-server-programs): properly close parenthesis.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/521
Steven vanZyl [Fri, 14 Aug 2020 14:44:38 +0000 (10:44 -0400)]
Add built-int support for godot engine
Copyright-paperwork-exempt: yes
Co-authored-by: João Távora <joaotavora@gmail.com>
* README.md: mention Godot
* eglot.el (eglot-server-programs): Add godot engine via port
GitHub-reference: close https://github.com/joaotavora/eglot/issues/511
Andrew Schwartzmeyer [Sun, 21 Jun 2020 04:47:04 +0000 (21:47 -0700)]
Ensure completion terminates in correct buffer
To design a completion-in-region-function replacement that leverages
the elements in completion-at-point-functions, we must ensure that
their :exit-function parts execute in the correct buffer. That is the
buffer where the text to be completed lives, not necessarily the
buffer being used for user interaction.
Later on, this guarantee should be provided by Emacs itself, perhaps
by putting the correct with-current-buffer call in completion--done.
Copyright-paperwork-exempt: yes
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-completion-at-point): Ensure :exit-function's
buffer is where the source is.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/505
João Távora [Mon, 13 Jul 2020 22:59:41 +0000 (23:59 +0100)]
Use a hash-table for storing resolved completions
* eglot.el (eglot-completion-at-point): use a hash-table for
storing resolved completions.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/510
João Távora [Mon, 13 Jul 2020 22:43:35 +0000 (23:43 +0100)]
Reload eldoc if needed on emacs < 28
ElDoc is preloaded in Emacs, so `require`-ing won't guarantee we are
using the latest version from GNU Elpa when we load eglot.el. Use an
heuristic to see if we need to `load` it in Emacs < 28.
* eglot.el (Package-Requires): Require eldoc 1.5.0
(top): Sometimes load eldoc
João Távora [Fri, 10 Jul 2020 16:41:43 +0000 (00:41 +0800)]
Fix sorting of completion items
This fixes a problem pointed out by Yuwei Tian <ibluefocus@gmail.com>.
* eglot.el (eglot-completion-at-point): Fix getting :sortText content
of the completion item.
GitHub-reference: closes https://github.com/joaotavora/eglot/issues/509
João Távora [Thu, 9 Jul 2020 23:28:19 +0000 (00:28 +0100)]
* eglot.el (package-requires): require flymake 1.0.9 and eldoc 1.2.0
João Távora [Wed, 3 Jun 2020 17:40:58 +0000 (18:40 +0100)]
Delegate "hover" and "signature" doc synchronization efforts to eldoc
Uses Eldoc's eldoc-documentation-functions variable. In Eldoc v1.0.0
that variable was already available as a way of handling/composing
multiple docstrings from different sources, but it didn't work
practically with mutiple concurrent async sources. This was fixed in
1.1.0, which Eglot now requires.
This fixes the synchronization problems reported in https://github.com/joaotavora/eglot/issues/494 and also
issue https://github.com/joaotavora/eglot/issues/439. It is likely that some of the exact doc-composing
functionality in Eglot, (developed during those issues) was lost, and
has to be remade, quite likely in Eldoc itself.
Flymake is now also an Eldoc producer, and therefore the problems of
github issues https://github.com/joaotavora/eglot/issues/481 and https://github.com/joaotavora/eglot/issues/454 will also soon be fixed as soon as Eglot
starts using the upcoming Flymake 1.0.9.
* NEWS.md: New entry.
* README.md (eglot-put-doc-in-help-buffer)
(eglot-auto-display-help-buffer): Remove mention to these options.
* eglot.el
(Package-Requires:) Require eldoc.el 1.1.0.
(eglot--when-live-buffer): Rename from eglot--with-live-buffer.
(eglot--when-buffer-window): New macro.
(eglot--after-change, eglot--on-shutdown, eglot-ensure): Use eglot--when-live-buffer.
(eglot--managed-mode): Use eglot-documentation-functions and eldoc-documentation-strategy.
(eglot--highlights): Move down.
(eglot-signature-eldoc-function, eglot-hover-eldoc-function)
(eglot--highlight-piggyback): New eldoc functions.
(eglot--help-buffer, eglot--update-doc)
(eglot-auto-display-help-buffer, eglot-put-doc-in-help-buffer)
(eglot--truncate-string, eglot-doc-too-large-for-echo-area)
(eglot-help-at-point): Remove all of this.
(eglot--apply-workspace-edit): Call eldoc manually after an edit.
(eglot-mode-map): Remap display-local-help to eldoc-doc-buffer
João Távora [Sun, 31 May 2020 10:49:51 +0000 (11:49 +0100)]
Fix small problems around eglot's help buffer
Specifically:
- correctly format the message shown to the user about doc being truncated
- don't show message if the buffer is showing in some frame's window
- correctly name the help buffer switched to with `C-h .'.
This is still not ideal:
- When the `C-h .' suggestion is shown to the user, typing that keybinding
shouldn't result in a new LSP request to fetch probably the same info;
- All this functionality belongs in eldoc.el.
* eglot.el (eglot-help-at-point): Fix buffer name.
(eglot--update-doc): Provide more help.
Andrii Kolomoiets [Wed, 13 May 2020 07:48:26 +0000 (10:48 +0300)]
Simplify eglot-code-actions
If no region is active, ask for code actions at point, even if there
are no diagnostics at point.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot-code-actions): Simplify.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/473
Andrii Kolomoiets [Tue, 26 May 2020 20:03:39 +0000 (23:03 +0300)]
Use filter-buffer-substring to get buffer text
This way modes used to represent hover info text, such as
gfm-view-mode can e.g. filter out invisible text by providing own
`filter-buffer-substring-function'.
* eglot.el (eglot--format-markup): Use `filter-buffer-substring'.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/482
João Távora [Mon, 25 May 2020 10:18:21 +0000 (11:18 +0100)]
Replace uses of project-roots with project-root
* eglot.el (Package-Requires): Require project 0.3.0.
(eglot--connect, eglot-handle-request)
(eglot-initialization-options, eglot--eclipse-jdt-contact): Use
project-root.
Gary Oberbrunner [Tue, 26 May 2020 13:13:44 +0000 (14:13 +0100)]
Also consider label of a completionitem for snippets
Copyright-paperwork-exempt: yes
* eglot.el (eglot-completion-at-point): Consider label when
expanding snippets.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/480
Andrii Kolomoiets [Wed, 6 May 2020 19:06:35 +0000 (22:06 +0300)]
Rework computation of string given to eldoc (again)
Co-authored-by: Andreii Kolomoiets <andreyk.mad@gmail.com>
Also do some refactoring to join similar logic in
eglot-doc-too-large-for-echo-area and eglot--truncate-string.
* eglot.el (eglot-doc-too-large-for-echo-area): Now returns the
number of lines available.
(eglot--truncate-string): New helper.
(eglot--first-line-of-doc, eglot--top-lines-of-doc): Remove.
(eglot--update-doc): Use new helpers.
* eglot-tests.el (hover-multiline-doc-locus): New test
GitHub-reference: close https://github.com/joaotavora/eglot/issues/459
Philipp Stephani [Mon, 25 May 2020 09:30:32 +0000 (11:30 +0200)]
Fix type error in eglot--xref-make-match
Its first argument is passed to xref-make-match, which expects a string
as its SUMMARY argument, but symbol-at-point returns a symbol.
Co-authored-by: João Távora <joaotavora@gmail.com>
* eglot.el (eglot--lsp-xrefs-for-method): use symbol-name.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/488
Rudolf Schlatte [Thu, 21 May 2020 09:20:41 +0000 (11:20 +0200)]
Add support for erlang_ls
* README.md: Mention erlang_ls
* eglot.el (eglot-server-programs): Add erlang_ls
GitHub-reference: close https://github.com/joaotavora/eglot/issues/471
João Távora [Mon, 18 May 2020 12:10:13 +0000 (13:10 +0100)]
Correctly place diagnostics in narrowed buffers
* eglot.el (eglot--lsp-position-to-point)
(eglot-handle-notification): save-restriction and widen
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/479
João Távora [Thu, 14 May 2020 22:10:48 +0000 (23:10 +0100)]
Require xref, project and eldoc from gnu elpa
* Makefile (ELPADEPS): Install Xref, Project and Eldoc.
* eglot.el (Package-Requires): Require Xref, Project and Eldoc
from GNU ELPA.
Dan Davison [Thu, 14 May 2020 00:06:35 +0000 (20:06 -0400)]
Prompt for executable if supplied name does not exist
* eglot.el (eglot--guess-contact): Interpret a list containing a
single string as an executable when forming the interactive prompt.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/474
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/478
Dan Davison [Tue, 12 May 2020 15:50:56 +0000 (11:50 -0400)]
Don't call flymake report function if flymake is disabled
Also fix https://github.com/joaotavora/eglot/issues/472.
Copyright-paperwork-exempt: yes
* eglot.el (eglot-handle-notification): Check that flymake-mode is
active before calling flymake report function.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/468
Tobias Rittweiler [Thu, 7 May 2020 22:51:44 +0000 (00:51 +0200)]
Fix "free variable" warning
* eglot.el (eglot-events-buffer): Use `eglot-current-server' instead
of `eglot--cached-server' because the latter is declared later in
the file.
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/460
Andrii Kolomoiets [Wed, 6 May 2020 21:35:48 +0000 (00:35 +0300)]
Remove trailing whitespaces
* eglot.el (defvar company-backends, eglot-code-actions):
Remove trailing whitespace